from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time



"""
	用户登录的操作
	包含输入信息
	获取点击登陆后的时间，如登陆失败后弹出的文字，账号或者密码错误
"""
class UserLoginPage:
	
	def __init__(self, driver):
		self.driver = driver

	def login_page(self,username,password):

		self.driver.find_element(By.ID, "username").send_keys(username)
		self.driver.find_element(By.NAME, "password").send_keys(password)
		self.driver.find_element(By.TAG_NAME, "button").click()
		# return self
		# time.sleep(1)



		# self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/a').click()
		# self.driver.find_element(By.XPATH, '/html/body/div/div/aside/div[2]/nav/ul/li[2]/ul/li[1]/a').click()
		# self.driver.find_element(By.XPATH,
		# 							 '/html/body/div/div/main/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[6]/button').click()
		# time.sleep(1)
		# MyPassword.pas_in(self.driver)
		
	def login_success_get_massage(self):
		return self.driver.find_element(By.XPATH, "/html/body/div/div/aside/div[1]/a").text
	
	def login_name_error_get_massage(self):
		return self.driver.find_element(By.XPATH, "/html/body/div/div/div/form/div[1]/span[1]").text
	
	def login_password_error_get_massage(self):
		return self.driver.find_element(By.XPATH, "/html/body/div/div/div/form/div[2]/span[1]").text





















